public class HappyCount {
    public boolean test(int num){
        int i = square(num);
        int j = num;
        while (i != j){
            i = square(square(i));
            j = square(j);
        }
        if (i == 1){
            return true;
        }
        return false;
    }
    public int square(int num){
        int cur = 0;
        while(num != 0){
            cur += (num % 10)*(num % 10);
            num = num / 10;
        }
        return cur;
    }

}
